﻿Public Class NhanVienDAO
    Public Shared Function NhanVien_Load() As DataTable
        Return DataProvider.LoadTable("Select * from NhanVien")
    End Function


    Public Shared Sub NhanVien_Insert(ByVal nv As NhanVienDTO)
        Dim Npara As Integer = 7
        Dim sql As String = "usp_NHANVIEN_InsertNHANVIEN"
        Dim name As String() = New String(Npara - 1) {}
        Dim value As Object() = New Object(Npara - 1) {}
        name(0) = "@tennv"
        name(1) = "@CMND"
        name(2) = "@NGAYsinh"
        name(3) = "@DiaChi"
        name(4) = "@sdt"
        name(5) = "@MaCV"
        name(6) = "@MANV"
        nv.Manv = AutoInc.AutoIncInt(NhanVienDAO.NhanVien_Load, "MANV")
        value(0) = nv.Tennv
        value(1) = nv.Cmnd
        value(2) = nv.Ngaysinh
        value(3) = nv.Diachi
        value(4) = nv.Sdt
        value(5) = nv.Macv
        value(6) = nv.Manv
        DataProvider.ExecuteNonQueryPara(sql, name, value, Npara)
    End Sub

    Public Shared Sub NhanVien_Update(ByVal nv As NhanVienDTO)
        Dim Npara As Integer = 7
        Dim sql As String = "usp_NHANVIEN_updateNHANVIEN"
        Dim name As String() = New String(Npara - 1) {}
        Dim value As Object() = New Object(Npara - 1) {}
        name(0) = "@tennv"
        name(1) = "@CMND"
        name(2) = "@NGAYsinh"
        name(3) = "@DiaChi"
        name(4) = "@sdt"
        name(5) = "@MaCV"
        name(6) = "@MANV"
        value(0) = nv.Tennv
        value(1) = nv.Cmnd
        value(2) = nv.Ngaysinh
        value(3) = nv.Diachi
        value(4) = nv.Sdt
        value(5) = nv.Macv
        value(6) = nv.Manv
        DataProvider.ExecuteNonQueryPara(sql, name, value, Npara)
    End Sub
    Public Shared Sub NhanVien_Delete(ByVal nv As NhanVienDTO)
        Dim sql As String = String.Format("delete NhanVien where MANV = {0}", nv.Manv)
        DataProvider.ExecuteNonQuery(sql)
    End Sub
End Class
